local s15__ganglie = fk.CreateSkill {
  name = "s15__ganglie",
}

Fk:loadTranslationTable {
  ["s15__ganglie"] = "刚烈",
  [":s15__ganglie"] = "当你受到1点伤害后,你可以选择一名敌方角色，然后你进行一次判定,若结果为:红色,你对其造成1点伤害;黑色,你弃置其一张牌。",

  ["#s15__ganglie-choose"] = "刚烈：选择一名敌方角色，你进行判定，红色对其造成1点伤害，黑色弃置其一张牌",

  ["$s15__ganglie1"] = "鼠辈，竟敢伤我！",
  ["$s15__ganglie2"] = "以彼之道，还施彼身！",
}

s15__ganglie:addEffect(fk.Damaged, {
  anim_type = "masochism",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(s15__ganglie.name) and data.damage == 1 and #player:getEnemies() > 0
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local to = room:askToChoosePlayers(player, {
      targets = player:getEnemies(),
      min_num = 1,
      max_num = 1,
      prompt = "#s15__ganglie-choose",
      skill_name = s15__ganglie.name,
      cancelable = true,
    })
    if #to > 0 then
      event:setCostData(self, { tos = to })
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = event:getCostData(self).tos[1]
    local judge = {
      who = player,
      reason = s15__ganglie.name,
      pattern = ".|.|spade,club",
    }
    room:judge(judge)

    if not to.dead then
      if judge.card.color == Card.Red then
        -- 红色：造成1点伤害
        room:damage {
          from = player,
          to = to,
          damage = 1,
          skillName = s15__ganglie.name,
        }
      elseif judge.card.color == Card.Black then
        -- 黑色：弃置一张牌
        room:askToDiscard(to, {
          min_num = 1,
          max_num = 1,
          include_equip = true,
          skill_name = s15__ganglie.name,
          cancelable = false,
        })
      end
    end
  end,
})

return s15__ganglie
